<?php

namespace Home\Controller;

use Think\Controller;
use \Model\UserModel;
use \Model\SkillModel;
use \Home\Common\Aes;

class TestController extends Controller
{
    //图片上传测试类
	function test_img_upload()
	{
		if ($_FILES) {
			dump($_FILES);
			$cfg = array(
				'rootPath' => 'Public/Upload/test/', //保存根路径
				'subName' => "/", // 设置附件上传（子）目录
				'saveName' => array('microtime', 'true'), //上传文件命名规则，[0]-函数名，[1]-参数，多个参数使用数组
			);
	    //设置附件的存储位置
			$up = new \Think\Upload($cfg);
//	    dump($up);exit;
			$z = $up->upload($_FILES);
			dump($z);

		} else {
			$this->display();
		}
	}
    
    
    //测试地址
	public function test_address_url()
	{
		$this->display();
	}


	//内部测试：获取验证码(GET请求)
	public function get_authcode_by_user_tel()
	{
		$user_tel = $_GET['user_tel'];
		$data = D('temp_user')->where('temp_user_tel')->find();
		// echo $data['temp_user_authcode'];
		$info['authcode'] = $data['temp_user_authcode'];
		$callback = $_GET['callback'];
		echo $callback."(".json_encode($info).")";

	}

	//内部测试：获取验证码(POST请求)
	public function get_authcode_by_user_tel2()
	{
		// $user_tel = $_POST['user_tel'];
		$data = D('temp_user')->where('temp_user_tel')->find();
		// echo $data['temp_user_authcode'];
		$info['authcode'] = $data['temp_user_authcode'];
		$callback = $_GET['callback'];
		// echo $callback."(".json_encode($info).")";
		echo json_encode($info);

	}


	public function test() {
		// $info = new Aes;
		// $info->test();
        $skill = D('skill');

		// $skillmodel = new SkillModel;
		$skill_state = $skill->where('skill_id=117')->find();
		echo $skill_state;

	}

	public function mysqladd() {
		$test = D('test');

		$data = array(
			"test_value1" => "123456789123456789dfadfdfasdfwqerfdfasdfasdf",
			"test_value2" => "123456789123456789dfadfdfasdfwqerfdfasdfasdf",
			"test_value3" => "123456789123456789dfadfdfasdfwqerfdfasdfasdf",
			"test_value4" => "123456789123456789dfadfdfasdfwqerfdfasdfasdf",
			"test_value5" => "123456789123456789dfadfdfasdfwqerfdfasdfasdf",
			"test_value6" => "123456789123456789dfadfdfasdfwqerfdfasdfasdf",
			"test_value7" => "123456789123456789dfadfdfasdfwqerfdfasdfasdf",
			"test_value8" => "123456789123456789dfadfdfasdfwqerfdfasdfasdf",
			"test_value9" => "123456789123456789dfadfdfasdfwqerfdfasdfasdf",
			"test_value10" => "123456789123456789dfadfdfasdfwqerfdfasdfasdf"
		);
		for($i=0;$i<10000;$i++) {
			$info = $test->add($data);
		}

		echo "ok";exit;

	}

}
